package com.zerowidth.moc.web.bean;

/**
 * 游戏全部随机配置关键种子
 * 注：所有配置数组都是从容易到困难
 */
public class SeedConfigTest {

    /**
     * 大苹果跑马灯的数量
     */
    private static final int BIG_APPLE_COUNT = 4;


    public static int[] seedIndexConfig = {0, 0, 0, 0, 0};

    public static void reset(){
        seedIndexConfig = new int[]{0, 0, 0, 0, 0};
    }

    public static void moveSeedIndex() {

        seedIndexConfig[0]++;
        seedIndexConfig[0] = round(seedIndexConfig[0], firstRunWeightConfigArr.length - 1, 0);

        seedIndexConfig[1]++;
        seedIndexConfig[1] = round(seedIndexConfig[1], luckResultWeightConfigArr.length - 1, 0);

        seedIndexConfig[2]++;
        seedIndexConfig[2] = round(seedIndexConfig[2], rateConfigArr.length - 1, 0);

        seedIndexConfig[3]++;
        seedIndexConfig[3] = round(seedIndexConfig[3], luckHitWeightConfigArr.length - 1, 0);

        seedIndexConfig[4]++;
        seedIndexConfig[4] = round(seedIndexConfig[4], compareWinWeightConfigArr.length - 1, 0);
    }

    private static int round(int target, int max, int defaultValue) {
        if (target == max) {
            return defaultValue;
        }
        return Math.min(target, max);
    }

    /**
     * 24个灯，共 240 份权重，平均每灯 10 权重。
     * 注：这里自由分配权重，为方便理解，需要保持总权重=240
     * <p>
     * 顺序 = [小元大灯1，小元大灯2，小元小灯，大元大灯，大元小灯，
     * 大苹果，小苹果，大BAR，小BAR,
     * Luck左，Luck右]
     */
    public static final int[][] firstRunWeightConfigArr = {
            {15, 15, 0, 20, 0, /**/ 4, 0, 5, 5, /**/ 10 + (6 * BIG_APPLE_COUNT) + 5, 10 + 10 + 5}, // 非常容易，只会中大灯
            {13, 13, 4, 16, 4, /**/ 6, 5, 2, 3, /**/ 10 + (4 * BIG_APPLE_COUNT) + 8, 10 + 5 + 7},
            {11, 11, 8, 12, 8, /**/ 8, 8, 2, 3, /**/ 10 + (2 * BIG_APPLE_COUNT) + 8, 10 + 2 + 7},
            {10, 10, 10, 10, 10, /**/ 10, 10, 2, 3, /**/ 10 + 8, 10 + 7},
            {8, 8, 14, 7, 13, /**/ 10, 10, 1, 2, /**/ 10 + 9, 10 + 8},
            {5, 5, 20, 5, 15, /**/ 10, 10, 1, 2, /**/ 10 + 9, 10 + 8},
            {2, 2, 26, 2, 18, /**/ 5, 5, 0, 1, /**/ 10 + 5 * BIG_APPLE_COUNT + 10, 10 + 5 + 9},
            {0, 0, 30, 0, 20, /**/ 3, 5, 0, 0, /**/ 10 + 7 * BIG_APPLE_COUNT + 10, 10 + 5 + 10} // 非常困难，只会中小灯

    };

    /**
     * Luck灯全部激活结果的概率
     * [失败，一灯，二灯，三灯，四灯，小三，大三，大四，大满，纵横，小满
     * 数组长度 = 11
     */
    public static final double[][] luckResultWeightConfigArr = {
            {0.0, 0.4, 0.5, 0.55, 0.6, 0.7, 0.8, 0.9, 0.94, 0.99, 1.0},   // 绝对不熄火
            {0.1, 0.45, 0.5, 0.55, 0.6, 0.7, 0.8, 0.9, 0.94, 0.99, 1.0},
            {0.2, 0.5, 0.65, 0.7, 0.75, 0.8, 0.84, 0.90, 0.915, 0.95, 1.0},
            {0.3, 0.5, 0.65, 0.7, 0.75, 0.8, 0.84, 0.90, 0.915, 0.95, 1.0},
            {0.4, 0.6, 0.65, 0.7, 0.75, 0.8, 0.84, 0.90, 0.915, 0.95, 1.0},
            {0.5, 0.6, 0.65, 0.7, 0.75, 0.8, 0.84, 0.90, 0.915, 0.95, 1.0},
            {0.7, 0.75, 0.77, 0.79, 0.81, 0.86, 0.9, 0.94, 0.95, 0.99, 1.0},
            {0.75, 0.8, 0.82, 0.85, 0.87, 0.9, 0.93, 0.95, 0.955, 0.99, 1.0},
            {0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0},
            {1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0},   //绝对熄火
    };

    /**
     * Luck 幸运枪 命中各跑马灯的 权重
     * 顺序 = [小元大灯1，小元大灯2，小元小灯，大元大灯，大元小灯，大苹果，小苹果，大BAR，小BAR]
     */
    public static final int[][] luckHitWeightConfigArr = {
            {10, 10, 0, 10, 0, 5, 0, 2, 4},
            {10, 10, 5, 10, 5, 5, 0, 2, 4},
            {10, 10, 5, 10, 5, 10, 5, 2, 3},
            {10, 10, 10, 10, 10, 10, 5, 2, 3},
            {10, 10, 20, 10, 20, 10, 10, 1, 2},
            {8, 8, 14, 8, 22, 10, 10, 1, 2},
            {5, 5, 20, 5, 15, 10, 10, 1, 1},
            {2, 2, 26, 3, 17, 10, 10, 0, 1},
            {1, 1, 28, 2, 18, 10, 10, 0, 0},
            {0, 0, 30, 0, 20, 0, 10, 0, 0},
    };

    /**
     * 倍率灯的权重
     */
    public static final int[][] rateConfigArr = {
            {10, 20, 70},
            {20, 30, 50},
            {35, 35, 30},
            {50, 25, 25},
            {70, 20, 10},
            {70, 25, 5},
            {85, 10, 5},
            {95, 5, 0},
            {100, 0, 0}
    };

    /**
     * 比倍赢的概率
     * 防止连续比倍胜率，2的10次方结果太过大，影响游戏体验
     */
    public static final float[] compareWinWeightConfigArr = {0.8f, 0.75f, 0.7f, 0.6f, 0.55f, 0.5f, 0.48f, 0.45f, 0.4f, 0.3f, 0.2f};

}